package _022_2_12

func search(nums []int, target int) int {
	l, r := 0, len(nums)-1

	if len(nums) <= 0 {
		return -1
	}

	if len(nums) == 1 {
		if nums[0] == target {
			return 0
		}
		return -1
	}

	for l < r {
		mid := (l + r) / 2
		if nums[mid] == target {
			return mid
		}
		if nums[0] < nums[mid] {
			if nums[l] < target && target < nums[mid] {
				r = mid - 1
			} else {
				l = mid + 1
			}
		} else {

		}
	}

	return -1
}
